<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="model.*"%>
<%@page import="db.DAOFactory"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Scene-map</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="/travel/resources/styles.css">
  </head>
  
  <body>
  	<% request.setCharacterEncoding("utf-8"); %>
    <div id="info">
		<input type="text" value="输入你要查询的关键字"/><input type="button" value="搜索景点"/>

	<%
		out.print("<p>point------------------------<p>");
		ArrayList<Spot> pointList=null;
		Spot point=null;	
		
		point = DAOFactory.getSpotDAO().findById(9);
		out.print("<p>object:"+point.getName()+"<p>");
		pointList=DAOFactory.getSpotDAO().findByKeyword("码头","描");
		for(Iterator i=pointList.iterator();i.hasNext();){
			out.print("<p>list:"+((Spot)i.next()).getName()+"<p>");
		}
		Spot newPoint=new Spot();
		newPoint.setId(10000);
		newPoint.setName("hahaneww");
		newPoint.setXpos(0);
		newPoint.setYpos(0);
		newPoint.setSight(point);
		newPoint.setDescription("new");
		newPoint.setPrice(500) ;
		newPoint.setUrl("");
		newPoint.setCreateDate(new Date());
		newPoint.setOwnerId(1);
		if(DAOFactory.getSpotDAO().save(newPoint))
			out.print("<p> save !!!!!<p>");
		else
			out.print("<p> save error!!!!!<p>");
		point = DAOFactory.getSpotDAO().findByName("hahaneww");
		point.setName("哈哈xiu");
		DAOFactory.getSpotDAO().update(point);
		point = DAOFactory.getSpotDAO().findByName("哈哈xiu");
		if(point!=null)	
			out.print("<p> save select:"+point.getName()+"<p>");
		else
			out.print("<p> save select:null<p>");
		DAOFactory.getSpotDAO().delete(42);	
		point = DAOFactory.getSpotDAO().findById(42);
		if(point!=null)	
			out.print("<p>delete select:"+point.getName()+"<p>");
		else
			out.print("<p>delete select:null<p>");
		
		%>
    </div>
  </body>
</html>
